#!/usr/bin/python
# -*- coding: UTF-8 -*-
'''
Created on 11 jul 2011

@author: Joakim Lindskog

Copyright (c) 2011 Joakim Lindskog

This file is part of MyGarden.

    MyGarden is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    MyGarden is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with MyGarden.  If not, see <http://www.gnu.org/licenses/>.
'''
import tool, pyglet, util, events
from cocos.director import director

class HarvestShovel(tool.Tool):
    '''
    A small shovel for harvesting
    '''

    def __init__(self):
        '''
        Constructor
        '''
        super(HarvestShovel, self).__init__(util.load_image('shovel.png'))
        self.scale = .3
        self.anchor = 70,40
        
        # Target bed
        self.target = None
        
        # Use sound
        self.sound = util.load_effect('dig.ogg')
        
    def use(self, bed, x, y, button, modifiers):
        self.target = bed
        self.sound.play()
        # Dispatch event
        events.EventBus().dispatch_event(events.UseToolEvent(self, x, y, name="harvest_shovel"))
        
    def cancel(self):
        self.target = None
        
    def get_cursor(self):
        return director.interpreter_locals["director"].window.get_system_mouse_cursor(pyglet.window.BaseWindow.CURSOR_CROSSHAIR)
    
    def get_mouse_info_image(self):
        return self